package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.supervision.dto.create.SpAuditActionResultCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.SpAuditResultDTO;
import com.engine4cloud.tdf.supervision.entity.SpAuditResultEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.time.LocalDateTime;

@Mapper
public interface SpAuditResultConvert {
    SpAuditResultConvert INSTANCE = Mappers.getMapper(SpAuditResultConvert.class);

    SpAuditResultDTO convert(SpAuditResultEntity s);

    default SpAuditResultEntity create(SpAuditActionResultCreateDTO dto) {
        SpAuditResultEntity entity = new SpAuditResultEntity();
        entity.setRybh(dto.getRybh());
        entity.setLcbh(dto.getLcbh());
        entity.setYwlx(dto.getBusinessType());
        entity.setShjg(dto.getStatus());
        entity.setShsj(LocalDateTime.now());
        entity.setTenantId(dto.getTenantId());
        entity.setPreDeptId(dto.getPreDeptId());
        entity.setShry(dto.getShry());
        return entity;
    }

}
